package com.hinnotek.warehouse.bean

import android.graphics.Rect
import android.os.Parcel
import android.os.Parcelable.Creator
import android.widget.ImageView
import androidx.annotation.DrawableRes
import androidx.databinding.BindingAdapter
import com.bumptech.glide.Glide
import com.hinnotek.warehouse.R
import com.xuexiang.xui.widget.imageview.preview.enitity.IPreviewInfo
import com.xuexiang.xui.widget.imageview.preview.loader.GlideMediaLoader

/** 图片预览实体类  */
class ImageViewInfo : IPreviewInfo {
    /**
     * 图片地址
     */
     var mUrl: String
     var sUrl: String = ""

    /**
     * 记录坐标
     */
    var mBounds: Rect? = null
    var mVideoUrl: String? = null
    var description: String? = "描述信息"

    constructor(url: String) {
        mUrl = url
    }

    constructor(url: String, bounds: Rect?) {
        mUrl = url
        mBounds = bounds
    }

    constructor(videoUrl: String?, url: String) {
        mUrl = url
        mVideoUrl = videoUrl
    }

    override fun getUrl(): String { //将你的图片地址字段返回
        return mUrl
    }

    fun setUrl(url: String) {
        mUrl = url
    }

    override fun getBounds(): Rect? { //将你的图片显示坐标字段返回
        return mBounds
    }

    override fun getVideoUrl(): String? {
        return mVideoUrl
    }

    fun setBounds(bounds: Rect?) {
        mBounds = bounds
    }

    fun setVideoUrl(videoUrl: String?) {
        mVideoUrl = videoUrl
    }

    override fun describeContents(): Int {
        return 0
    }

    override fun writeToParcel(dest: Parcel, flags: Int) {
        dest.writeString(mUrl)
        dest.writeParcelable(mBounds, flags)
        dest.writeString(description)
        dest.writeString(mVideoUrl)
    }

    protected constructor(parcel: Parcel) {
        mUrl = parcel.readString()!!
        mBounds = parcel.readParcelable(Rect::class.java.classLoader)
        description = parcel.readString()
        mVideoUrl = parcel.readString()
    }

    companion object {



        fun newInstance(url: String, bounds: Rect?): List<ImageViewInfo> {
            return listOf(ImageViewInfo(url, bounds))
        }

        @JvmField
        val CREATOR: Creator<ImageViewInfo> = object : Creator<ImageViewInfo> {
            override fun createFromParcel(source: Parcel): ImageViewInfo {
                return ImageViewInfo(source)
            }

            override fun newArray(size: Int): Array<ImageViewInfo?> {
                return arrayOfNulls(size)
            }
        }
    }
}